package com.front.teacher.teacherapp.base;

/**

 */

import java.lang.ref.Reference;
import java.lang.ref.WeakReference;

/**
 *
 */
public class BasePresenter<IV> {
    private Reference<IV> view;

    public void attachView(IV v) {
        //封装避免内存泄漏
        view = new WeakReference<>(v);
    }

    public IV getView() {
        return view.get();
    }


    public boolean isAdd() {
        return view != null && view.get() != null;
    }
    public void detachView() {
        if (view != null) {
            view.clear();
            view = null;
        }
    }

}
